package love.yuanmengrobot.qdkaoqin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import love.yuanmengrobot.qdkaoqin.R;
import love.yuanmengrobot.qdkaoqin.entity.Clazz;
import love.yuanmengrobot.qdkaoqin.entity.Member;

public class ClazzAdapter extends ArrayAdapter<Clazz> {


    private List<Clazz> mClazzData;
    private Context mContext;
    private int resourceId;
    public ClazzAdapter(Context context,
                       int resourceId, List<Clazz> data) {
        super(context, resourceId, data);
        this.mContext = context;
        this.mClazzData = data;
        this.resourceId = resourceId;
    }
    @Override
    public View getView(int position,
                        View convertView, ViewGroup parent) {
        Clazz clazz = getItem(position);
        View view ;
        final ViewHolder vh;
        if (convertView == null) {
            view = LayoutInflater.from(getContext())
                    .inflate(resourceId, parent, false);
            vh = new ViewHolder();
            vh.tvClazzname  = view.findViewById(R.id.tv_clazz_name);
            vh.tvClazzid = view.findViewById(R.id.tv_clazz_id);

            view.setTag(vh);/////**
        } else {
            view = convertView;
            vh = (ViewHolder) view.getTag();
        }
        vh.tvClazzname.setText(clazz.getClazzname());
        vh.tvClazzid.setText("班级编号："+clazz.getClazzid());

        return view;
    }
    class ViewHolder {
        TextView tvClazzname;
        TextView tvClazzid;
    }


}
